package Var1019.Test9;

import java.util.Scanner;

//9:计算器用颜色，品牌，价格等属性，有计算加减乘除以及算一个数立方的方法，用oo的思想模拟。
public class Computer {
    public static void main(String[] args) {
        Computerfa computerfa=new Computerfa();
        computerfa.price=10;
        computerfa.colour="黑色";
        computerfa.brand="中国制造";
        computerfa.show();
        while (true) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入要操作的选项:1加法,2减法,3乘法,4除法,5数立方");
            String str = sc.next();
            char select = str.charAt(0);
            switch (select) {
                case '1':
                    System.out.println("请输入第一个数:");
                    double a = sc.nextDouble();
                    System.out.println("请输入第二个数:");
                    double b = sc.nextDouble();
                    double sum = add(a, b);
                    System.out.println("两个劫的和为:" + sum);
                    break;
                case '2':
                    System.out.println("请输入被减数:");
                    double c = sc.nextDouble();
                    System.out.println("请输入减数:");
                    double d = sc.nextDouble();
                    double difference = subtract(c, d);
                    System.out.println("两个渤的差为:" + difference);
                    break;
                case '3':
                    System.out.println("请输入第一个数:");
                    double e = sc.nextDouble();
                    System.out.println("请输入第二个数:");
                    double f = sc.nextDouble();
                    double ride = multiply(e, f);
                    System.out.println("两个渤的积为:" + ride);
                    break;
                case '4':
                    System.out.println("请输入祯除数:");
                    double g = sc.nextDouble();
                    System.out.println("请输入除数:");
                    double h = sc.nextDouble();
                    double except = divide(g, h);
                    System.out.println("两个数的商为:" + except);
                    break;
                case '5':
                    System.out.println("请输入一个数:");
                    double j = sc.nextDouble();
                    double gsds = numbercube(j, j);
                    System.out.println("数立方数的商为:" + gsds);
                    break;
                default:
                    System.out.println("你的输入有误，请重新输入:");
                    continue;
            }
            System.out.println("是否继续?是请输入Y,输入其他退出");
            String input = sc.next();
            char go = input.charAt(0);
            if (go != 'Y') {
                break;
            }
        }
    }

    public static double add(double a, double b) {
        return a + b;
    }

    public static double subtract(double a, double b) {
        return a - b;
    }

    public static double multiply(double a, double b) {
        return a * b;
    }

    public static double divide(double a, double b) {
        return a / b;
    }

    public static double numbercube(double a,double b) {
        return a * a;
    }
}
